package com.xhg.common.auth;

import org.apache.shiro.authc.UsernamePasswordToken;

import com.xhg.model.User;


public class UserToken extends UsernamePasswordToken {

	private static final long serialVersionUID = 6787344269886036610L;

	private User user;
	
	public UserToken() {
		super();
	}
	public UserToken(User user,boolean rememberMe) {
		super(user.getStr("userName"),user.getStr("password"),rememberMe);
		this.user = user;
	}
	@Override
	public String getUsername() {
		return user.getStr("userName");
	}
	@Override
	public char[] getPassword() {
		return user.getStr("password").toCharArray();
	}
	@Override
	public Object getPrincipal() {
		return user;
	}
	@Override
	public Object getCredentials() {
		return user.getStr("password");
	}
	
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
}
